﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jacaranda.Model;

namespace Jacaranda.Rules
{
    public class MaxLength : ValidationRule
    {
        public MaxLength(int length)
        {
            Length = length;
        }

        public int Length { get; private set; }

        public override bool Validate(Entity entity, string propertyName, object propertyValue)
        {
            return propertyValue == null || ((string)propertyValue).Length <= Length;
        }
    }
}
